

import java.util.*;

public class Test {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        while (scanner.hasNext()){

            int length = scanner.nextInt();

            int[] a = new int[length];
            int tmp3 = 0, tmp5 = 0, count = 0;

            for (int i = 0; i < length; i++) {
                int temp = scanner.nextInt();

                if(temp % 5 == 0){
                    tmp5 += temp;
                }else if(temp % 3 == 0){
                    tmp3 += temp;
                }else{
                    a[count++] = temp;
                }
            }

            int sum = Math.abs(tmp3 -tmp5);
            System.out.println(f(0, sum, a, 0, count));

        }
    }

    private static boolean f(int result, int sum, int[] a, int i, int count){

        if(i == count){
            return Math.abs(result) == sum;
        }

        return f(result + a[i], sum, a, i+1, count) || f(result - a[i], sum, a, i+1, count);

    }

}
